﻿using System;
using System.Windows.Forms;
using CalcSharp.Core.Containers;

namespace CalcSharp.MDIUI.Dialogs
{
    /// <summary>
    /// Matrix Crop dialog
    /// </summary>
    public partial class MatrixCropDialog : Form
    {
        public MatrixCropDialog(AMatrix m)
        {
            InitializeComponent();
            this.NumECol.Maximum = m.Columns;
            this.NumERow.Maximum = m.Rows;
            this.NumSCol.Maximum = m.Columns - 1;
            this.NumSRow.Maximum = m.Rows - 1;
            this.NumERow.Value = m.Rows;
            this.NumECol.Value = m.Columns;
            this.MtrxSize.Text = (this.NumERow.Value - this.NumSRow.Value).ToString() + " x " + (this.NumECol.Value - this.NumSCol.Value).ToString();
        }

        private void NumericChanged(object sender, EventArgs e)
        {
            this.MtrxSize.Text = (this.NumERow.Value - this.NumSRow.Value).ToString() + " x " + (this.NumECol.Value - this.NumSCol.Value).ToString();
        }

        /// <summary>
        /// Gets or sets the start row
        /// </summary>
        public int RowStart
        {
            get { return (int)NumSRow.Value; }
            set { NumSRow.Value = value; }
        }

        /// <summary>
        /// Gets or sets the start column
        /// </summary>
        public int ColumnStart
        {
            get { return (int)NumSCol.Value; }
            set { NumSCol.Value = value; }
        }

        /// <summary>
        /// Gets or sets the end row
        /// </summary>
        public int RowEnd
        {
            get { return (int)NumERow.Value; }
            set { NumERow.Value = value; }
        }

        /// <summary>
        /// Gets or sets the end column
        /// </summary>
        public int ColumnEnd
        {
            get { return (int)NumECol.Value; }
            set { NumECol.Value = value; }
        }
    }
}
